<template>
	<view class="container">
		<view class="contenter">
			<view class="toutus">
			<view class="toutu">
				<image src="/static/icon/logo1.png" mode=""></image>
			</view>	
			<text>XGT</text>
			</view>
			
		<view class="content">
			<ayQrcode ref="qrcode3" qrcode_id="qrcode3" :modal="modal_qr" :url="url" @hideQrcode="hideQrcode"
				:height="280" :width="280" themeColor="#000" :is_themeImg="true" themeImg="/static/icon/logo2.png"
				:h_w_img="60" />
		</view>	
		<view class="content2">
			<text>{{$t('duihuan.shoayishao')}}</text>
		</view>
		</view>
		
	</view>
</template>

<script>
	import ayQrcode from "@/components/ay-qrcode/ay-qrcode.vue"
	export default {
		components: {
			ayQrcode

		},
		data() {
			return {
				//二维码相关参数
				modal_qr: false,
				dizhi:'',
				url: '', // 要生成的二维码值

			}
		},
		created() {
			let that = this;
			that.getuserinfo()
		},

		onLoad() {
			uni.setNavigationBarTitle({
			  title:  this.$t('duihuan.myerwei'), // 必填，页面标题）
			 })
		},
		methods: {
			getuserinfo() {
				let data = {}
				let opts = {
					url: '/user/GetUserInfo',
					method: 'GET'
				};
				this.api.httpTokenRequest(opts, data).then(res => {
					// console.log('个人资料', res);
					if (res[1].data.state == 'success') {
						let address = res[1].data.list[0].dizhi
						//加密值
						this.dizhi = this.AES.encrypt(address,'1234567891234567','1234567891234567')
						this.url=`https://www.usxgt.com/#/pages/duihuan/erweima?dizhi=`+this.dizhi
						this.showQrcode(); //一加载生成二维码
					}
			
				})
			},

			// 展示二维码
			showQrcode() {
				let _this = this;
				this.modal_qr = true;
				uni.showLoading()
				setTimeout(function() {
					uni.hideLoading()
					_this.$refs.qrcode3.crtQrCode()
				}, 50)
			},

			//传入组件的方法
			hideQrcode() {
				this.modal_qr = false;
			},
		}

	}
</script>

<style>
	.container{
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	.toutus{
		width: 96%;
		margin-top: 40rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		font-size: 26px;
		font-weight: bold;
		color: #000;
	}
	.toutu{
		width: 80rpx;
		height: 80rpx;
		margin-right: 15rpx;
	}
	.contenter{
		width: 100%;
		height: 540px;
		background-color: #fff;
		border-radius: 20rpx;
		margin-top: 120rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.content{
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		margin: 40rpx;
	}
	.content2{
		width: 80%;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #000;
	}
</style>